package com.fengycx.remote.impl;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.bean.BeanUtil;
import com.fengycx.feign.AppLoginApi;
import com.fengycx.pojo.domain.Login;
import com.fengycx.pojo.param.AppLoginApiParam;
import com.fengycx.result.R;
import com.fengycx.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class AppLoginApiImpl implements AppLoginApi {

    @Autowired
    private ILoginService loginService;

    @Override
    @Transactional
    @SaIgnore
    public R<Boolean> appLogin(AppLoginApiParam appLoginApiParam) {
        Login login = new Login();
        BeanUtil.copyProperties(appLoginApiParam,login);
        login.setCreateTime(new Date());
        login.setName(appLoginApiParam.getNickName());
        loginService.save(login);
        return R.success();
    }
}
